<html>
<head><meta charset="utf-8"><title>Intrinsic for freezing bytes · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html">Intrinsic for freezing bytes</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="176085811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176085811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176085811">(Sep 19 2019 at 10:29)</a>:</h4>
<p>Hi all,</p>
<p>There was a discussion at <a href="https://bugs.llvm.org/show_bug.cgi?id=42435" target="_blank" title="https://bugs.llvm.org/show_bug.cgi?id=42435">https://bugs.llvm.org/show_bug.cgi?id=42435</a> with <span class="user-mention" data-user-id="120791">@RalfJ</span> about introducing an operation that replaces uninitialized bytes with arbitrary(but defined) bytes, which will be helpful for implementing fast memory initialization in Rust (e.g. <a href="https://github.com/rust-lang/rust/pull/58363" target="_blank" title="https://github.com/rust-lang/rust/pull/58363">https://github.com/rust-lang/rust/pull/58363</a> ).<br>
Here is a prototype of a patch that adds intrinsic <code>llvm.freeze_mem</code> to LLVM: <a href="https://github.com/aqjune/llvm-freeze/tree/freeze_mem" target="_blank" title="https://github.com/aqjune/llvm-freeze/tree/freeze_mem">https://github.com/aqjune/llvm-freeze/tree/freeze_mem</a> .<br>
It is either lowered into no-op assembly, or single round-trip of one-byte load/store assembly to address the case when OS may change bytes of untouched memory.</p>
<p>Rather than pushing this patch by myself, it will be great if anyone who is working both in LLVM and Rust could take this patch and drive instead, because I and colleagues are already pushing freeze instruction to LLVM (pushing llvm.freeze_mem by us might possibly distract people (e.g. people can assume that we're suggesting an alternative solution to freeze, which is not), which is not desirable).</p>
<p>Currently this patch works without compiler crash and is tested with SPEC CPU2017 (I tested with Clang that inserts llvm.freeze_mem after alloca). It is tested on x86-64, but not on other architectures.<br>
Also, several memory related optimizations should be updated so they’re aware of this intrinsics, which is not included in the patch above.</p>
<p>Introducing anyone who might be interested in this patch is greatly welcome.<br>
I’ll gladly be of help if have any inquiry. :)</p>



<a name="176095922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176095922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176095922">(Sep 19 2019 at 12:56)</a>:</h4>
<blockquote>
<p>If it is true, this is lowered into assembly that reads a random one byte<br>
between <code>%ptr</code> and <code>%ptr + %size - 1</code> and writes it back to the same<br>
address.</p>
</blockquote>
<p>Note that this is probably overkill</p>



<a name="176095930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176095930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176095930">(Sep 19 2019 at 12:56)</a>:</h4>
<p>You only need to touch one byte per memory page.</p>



<a name="176096168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176096168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176096168">(Sep 19 2019 at 12:59)</a>:</h4>
<blockquote>
<p>After <code>freeze_mem(ptr, size, touch_mem)</code> is called, it is<br>
guaranteed that there is no undef or poison bit in bytes from <code>ptr</code> to<br>
<code>ptr + size - 1</code>. Calculation of <code>ptr + size - 1</code> follows the way how<br>
getelementptr is evaluated.</p>
</blockquote>
<p>There are no tests checking that this is the case AFAICT</p>



<a name="176096291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176096291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176096291">(Sep 19 2019 at 13:00)</a>:</h4>
<blockquote>
<p>Also, several memory related optimizations should be updated so they’re aware of this intrinsics, which is not included in the patch above.</p>
</blockquote>
<p>Is there a different patch including these ?</p>



<a name="176096331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176096331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176096331">(Sep 19 2019 at 13:01)</a>:</h4>
<blockquote>
<p>If <code>touch_mem</code> is true and <code>size</code> is larger than the size of one page<br>
(which is determined at runtime),<br>
only one of the pages that this <code>freeze_mem</code> spans is touched.</p>
</blockquote>
<p>This behavior is incorrect right ?</p>



<a name="176096343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176096343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176096343">(Sep 19 2019 at 13:01)</a>:</h4>
<p>Each page must be touched</p>



<a name="176096361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176096361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176096361">(Sep 19 2019 at 13:01)</a>:</h4>
<p>otherwise the content of these other pages has not been frozen</p>



<a name="176098337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176098337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176098337">(Sep 19 2019 at 13:23)</a>:</h4>
<p>Hi @gnzlbg ! :D</p>
<blockquote>
<blockquote>
<p>If <code>touch_mem</code> is true and <code>size</code> is larger than the size of one page<br>
(which is determined at runtime),<br>
only one of the pages that this <code>freeze_mem</code> spans is touched.</p>
</blockquote>
<p>This behavior is incorrect right ?</p>
</blockquote>
<p>It depends on how Rust inserts llvm.freeze_mem.<br>
In my patch, I was assuming that Rust should insert a loop that looks like this:</p>
<div class="codehilite"><pre><span></span>while (ptr &lt; ptr_end) {
  llvm.freeze_mem(ptr, min(PAGE_SIZE, ptr_end - ptr))
  ptr += PAGE_SIZE
}
</pre></div>


<p>Another choice would be to let <code>llvm.freeze_mem</code> emit assembly with loops, but guess the result would be the same if LLVM's loop analyzer is taught about what <code>llvm.freeze_mem</code> is.</p>



<a name="176098456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176098456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176098456">(Sep 19 2019 at 13:25)</a>:</h4>
<blockquote>
<blockquote>
<p>Also, several memory related optimizations should be updated so they’re aware of this intrinsics, which is not included in the patch above.</p>
</blockquote>
<p>Is there a different patch including these ?</p>
</blockquote>
<p>No, this was kind of a very beginning phase, so there was no updates on optimizers yet.</p>



<a name="176098547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176098547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176098547">(Sep 19 2019 at 13:26)</a>:</h4>
<blockquote>
<p>You only need to touch one byte per memory page.</p>
</blockquote>
<p>This is true - but it is pretty hard to statically determine in a compiler whether two allocations are in the same page, I believe, especially because unused mallocs can be removed.</p>



<a name="176098671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176098671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176098671">(Sep 19 2019 at 13:27)</a>:</h4>
<blockquote>
<p>In my patch, I was assuming that Rust should insert a loop that looks like this:</p>
</blockquote>
<p>That makes sense</p>



<a name="176098890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176098890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176098890">(Sep 19 2019 at 13:29)</a>:</h4>
<p>I'm not sure whether it is better to have an intrinsic with the <code>touch</code> option, or two intrinsics, but that probably does not matter</p>



<a name="176098965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176098965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176098965">(Sep 19 2019 at 13:30)</a>:</h4>
<p>It would be great if there would be an optimization to turn a freeze with touch == true to touch == false</p>



<a name="176099005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099005">(Sep 19 2019 at 13:30)</a>:</h4>
<p>E.g., if the memory is on the stack, then there is no need to touch it, ever, AFAICT</p>



<a name="176099226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099226">(Sep 19 2019 at 13:32)</a>:</h4>
<p>What kind of load does freeze with touch = true currently perform ? In the code it seems that it does a volatile load</p>



<a name="176099240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099240">(Sep 19 2019 at 13:32)</a>:</h4>
<p>But wouldn't this be UB if that load where to race ?</p>



<a name="176099341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099341">(Sep 19 2019 at 13:33)</a>:</h4>
<blockquote>
<p>It would be great if there would be an optimization to turn a freeze with touch == true to touch == false</p>
</blockquote>
<p>Yep, this will be a great optimization. The transformation is valid when any store to a pointer within the range precedes or directly follows the <code>llvm.freeze_mem</code>.</p>



<a name="176099355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099355">(Sep 19 2019 at 13:33)</a>:</h4>
<p>Avoiding the race would need a volatile relaxed load, but I don't know if that is supported on all backends</p>



<a name="176099574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099574">(Sep 19 2019 at 13:36)</a>:</h4>
<blockquote>
<p>But wouldn't this be UB if that load where to race ?</p>
</blockquote>
<p>Yeah, data race should be UB by definition. It can raise UB if the given pointer is not dereferenceable (e.g. dangling pointer) as well<br>
If touch_mem is true, It is marked as volatile for convenience but not really needed to be volatile load, because adding a new memory attribute in SelectionDAG seemed to be a pretty hard work (it is just used for convenience).</p>



<a name="176099650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099650">(Sep 19 2019 at 13:36)</a>:</h4>
<p>Not by definition, sorry. It should be added to the definition in LangRef.</p>



<a name="176099967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/176099967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#176099967">(Sep 19 2019 at 13:39)</a>:</h4>
<p>I see. So I'd recommend updating the docs to include this information.</p>



<a name="177710447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177710447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177710447">(Oct 09 2019 at 12:55)</a>:</h4>
<blockquote>
<blockquote>
<p>You only need to touch one byte per memory page.</p>
</blockquote>
<p>This is true - but it is pretty hard to statically determine in a compiler whether two allocations are in the same page, I believe, especially because unused mallocs can be removed.</p>
</blockquote>
<p>it should be fairly easy though to do a loop that increments by 4096 and touches bytes until leaving the given range? the backend should know the page size</p>



<a name="177710505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177710505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177710505">(Oct 09 2019 at 12:56)</a>:</h4>
<p><span class="user-mention" data-user-id="203193">@aqjune</span>  I think touching all the pages is needed or else we cannot give this intrinsics a sensible semantics in the LLVM abstract machine</p>



<a name="177710519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177710519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177710519">(Oct 09 2019 at 12:56)</a>:</h4>
<p>saying that "it freezes memory" is just incorrect with a compilation scheme that does not touch all pages</p>



<a name="177710554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177710554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177710554">(Oct 09 2019 at 12:57)</a>:</h4>
<p>also read-write races are not UB in LLVM, so LLVM lowering could easily do a normal non-atomic read here</p>



<a name="177782119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177782119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177782119">(Oct 10 2019 at 06:09)</a>:</h4>
<p>I am not sure whether there is an assembly instruction that returns the page size, but in the frontend linux has getpagesize() api. Calling getpagesize() may have a cost, so I believe it is good for programmer to explicitly call this so one can write optimized code.</p>



<a name="177782189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177782189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177782189">(Oct 10 2019 at 06:11)</a>:</h4>
<p>For the semantics of llvm.freeze_mem(ptr, size), we can say that it freezes one of the pages that [ptr, ptr+size) lies on. We can say that the page is given from the environment, as the pointer size does.</p>



<a name="177782358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177782358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> aqjune <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177782358">(Oct 10 2019 at 06:15)</a>:</h4>
<p>BTW, one thing that I realized about llvm.freeze_mem(ptr, size) was that, if (ptr + size - 1) and ptr are in different pages, the touching *ptr is not enough to freeze the page of *(ptr + size - 1).<br>
To support this, llvm.freeze_mem should be lowered into touches to *ptr and *(ptr + size - 1); I hope this would work.</p>



<a name="177788839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Intrinsic%20for%20freezing%20bytes/near/177788839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Intrinsic.20for.20freezing.20bytes.html#177788839">(Oct 10 2019 at 08:21)</a>:</h4>
<blockquote>
<p>For the semantics of llvm.freeze_mem(ptr, size), we can say that it freezes one of the pages that [ptr, ptr+size) lies on. We can say that the page is given from the environment, as the pointer size does.</p>
</blockquote>
<p>so pages are part of the LLVM abstract machine now? I think that'd be new</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>